package 动态规划;

/**
 * @author mubei
 * @date 2021/12/22
 * @description JZ47 礼物的最大价值
 */
public class Demo02 {


    public int maxValue (int[][] grid) {
        // write code here
        int n = grid.length;
        int m = grid[0].length;
        int dp[] = new int[m+1];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dp[j+1] = Math.max(dp[j+1],dp[j]) + grid[i][j];
            }
        }
        return dp[m];
    }

}
